use crate::utils::get_current_timestamp;
use tracing::info;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Ad {
    pub key_word: String,
    pub ad_type: String,
    pub id: i64,
    pub start_time: i64,
    pub end_time: i64,
}
impl Ad {
    pub fn new() -> Self {
        Ad {
            key_word: String::new(),
            ad_type: String::new(),
            id: 0,
            start_time: 0,
            end_time: 0,
        }
    }
    // pub fn set_key_word(&mut self, word: String) {
    //     self.key_word = word;
    // }
    // pub fn set_ad_type(&mut self, word: String) {
    //     self.ad_type = word;
    // }
    // pub fn set_id(&mut self, id: i64) {
    //     self.id = id;
    // }
    // pub fn set_start_time(&mut self, start_time: i64) {
    //     self.start_time = start_time;
    // }
    // pub fn set_end_time(&mut self, end_time: i64) {
    //     self.end_time = end_time;
    // }
}
// #[derive(Debug, sqlx::FromRow)]
// struct TbGov {
//     govid: i64,
// }
#[derive(Debug, Clone, PartialEq)]

pub struct Gov {
    pub stime: i64,
    pub key_word: String,
}
#[derive(Debug, Clone)]

pub struct Hot {
    pub key_word: String,
    pub category: String,
    pub onboard_time: i64,
    pub ontop_time: i64,
    pub channel_type: String,
    pub star_name: String,
    pub realpos: i16,
    pub raw_hot: i64,
    pub outrank_time: i64,
}
impl Hot {
    pub fn new() -> Self {
        Hot {
            key_word: String::new(),
            category: String::new(),
            onboard_time: 0,
            ontop_time: 0,
            channel_type: String::new(),
            star_name: String::new(),
            realpos: 0,
            raw_hot: 0,
            outrank_time: get_current_timestamp(),
        }
    }
    pub fn updata(&mut self, new: &Hot) {
        let timestamp: i64 = get_current_timestamp();
        if self.raw_hot < new.raw_hot {
            // info!(target:"updata raw_hot","{}:{}->{}",&new.key_word,self.raw_hot,new.raw_hot);
            self.raw_hot = new.raw_hot;
        }
        if self.realpos > new.realpos {
            // info!(target:"updata realpos","{}:{}->{}",&new.key_word,self.realpos,new.realpos);
            self.realpos = new.realpos;
        }
        self.outrank_time = timestamp;
        if self.ontop_time == 0 && new.realpos == 1 {
            self.ontop_time = timestamp;
            info!(target:"ontop","{}:登顶了！！！！",&new.key_word,)
        }
    }
}
//判断是否是同一条热搜
impl PartialEq for Hot {
    fn eq(&self, other: &Self) -> bool {
        self.key_word == other.key_word
    }
}
impl Eq for Hot {}
